home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
Add-Ons
/
4D
/
ComboBox 1.1.1
/
src
/
ComboBoxList.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-02-23
|
5KB
|
197 lines
//---------------------------------------------------------------------------------------
//
// ComboBoxList.c -- Source for ComboBox external list window process event handler
//
// Copyright ©1995-1996, Pensacola Christian College
//
// ======================================================================
// Change History
// ======================================================================
//
// 1.0 08/ /95 Steve Dwire
// Initial release
//
//---------------------------------------------------------------------------------------
#include <Ext4D.h>
#include <QuickDraw.h>
#include <Palettes.h>
#include "ComboBoxList.h" // Include your header here.
//---------------------------------------------------------------------------------
//
// FUNCTION: ListProcess
//
//---------------------------------------------------------------------------------
#if defined(powerc) || WINVER
void ListProcess(void)
#else
void main(void)
#endif
{
AreaHnd OldAreaHnd=NULL, CurrAreaHnd=NULL;
Boolean Done=false;
PackHnd PackDataHnd;
WindowPtr ListWindow;
EventRecord event;
ListProcInit(&PackDataHnd, &ListWindow);
while (!Done)
{
SystemTask();
if (WaitNextEvent(everyEvent,&event,60,NULL) && (event.what != kIdleEvt))
{
if(event.what == kTerminateProcess)
{
Done=true;
}
else
{
//Check status of current area
CurrAreaHnd = (*PackDataHnd)->CurrAreaHnd;
if(CurrAreaHnd)
{
// OK, now we can take care of the event we got.
switch(event.what)
{
case mouseDown:
ListMouseDown(CurrAreaHnd,&event,ListWindow);
break;
case updateEvt:
ListUpdate(CurrAreaHnd,&event,ListWindow);
break;
case activateEvt:
ListActivate(CurrAreaHnd,&event,ListWindow);
break;
}
}
}
}
}
ListProcDeInit(PackDataHnd,ListWindow);
}
//---------------------------------------------------------------------------------
//
// FUNCTION: ListProcInit
//
//---------------------------------------------------------------------------------
void ListProcInit(PackHnd* PackDataHndPtr, WindowPtr* ListWndPtr)
{
// Get the package handle out of ◊CB_PackData and store it in PackDataHnd.
ParameterBlock block;
ValuePtr value;
Rect bounds;
SWORD i;
for(i=1; i<=3; i++)
CALL4D (kEX_YIELD_ABSOLUTE,&block);
block.fName[0] = (SBYTE)11;
block.fName[1] = 'C';
block.fName[2] = 'B';
block.fName[3] = '_';
block.fName[4] = 'P';
block.fName[5] = 'a';
block.fName[6] = 'c';
block.fName[7] = 'k';
block.fName[8] = 'D';
block.fName[9] = 'a';
block.fName[10] = 't';
block.fName[11] = 'a';
block.fName[12] = '\0';
value = (ValuePtr) NewPtr(sizeof(ValueBlock));
block.fH = (XHANDLE)value;
CALL4D(kEX_GET_GLOBALVAR,&block);
*PackDataHndPtr = (PackHnd)(value->uValue.fLongint);
DisposePtr((Ptr) value);
// Create new (invisible) window for the lists
bounds.top = bounds.left = 1;
bounds.right = bounds.bottom = 2; // We'll resize the window before opening it
CALL4D(kEX_FLOATING_WINDOW,&block);
*ListWndPtr = NewCWindow(NULL,&bounds,NULL,false,plainDBox,NULL,false,0);
(**PackDataHndPtr)->ListWindow = *ListWndPtr;
CALL4D(kEX_CURRENT_ID,&block);
CALL4D(kEX_FREEZE_PROCESS,&block);
}
//---------------------------------------------------------------------------------
//
// FUNCTION: ListUpdate
//
//---------------------------------------------------------------------------------
void ListUpdate(AreaHnd AreaDataHnd, EventRecord* event, WindowPtr ListWindow)
{
GrafPtr savePort;
ListHandle ListHnd;
ParameterBlock block;
while((*AreaDataHnd)->Flags.ListDirty) // make sure the list is stable
CALL4D(kEX_YIELD_ABSOLUTE,&block); // before we draw it.
ListHnd = (*AreaDataHnd)->ListHnd;
if (ListHnd)
{
//saveListPort = (*ListHnd)->port;
GetPort(&savePort);
SetPort(ListWindow);
BeginUpdate(ListWindow);
//(*ListHnd)->port = savePort;
LUpdate(ListWindow->visRgn,ListHnd);
//(*ListHnd)->port = saveListPort;
EndUpdate(ListWindow);
SetPort(savePort);
}
}
//---------------------------------------------------------------------------------
//
// FUNCTION: ListActivate
//
//---------------------------------------------------------------------------------
void ListActivate(AreaHnd AreaDataHnd, EventRecord* event, WindowPtr ListWindow)
{
GrafPtr savePort;
if((*AreaDataHnd)->ListHnd)
{
GetPort(&savePort);
SetPort(ListWindow);
//LActivate(((event->modifiers & activeFlag) != 0), (*AreaDataHnd)->ListHnd);
LActivate(true, (*AreaDataHnd)->ListHnd);
SetPort(savePort);
}
}
//---------------------------------------------------------------------------------
//
// FUNCTION: ListProcDeInit
//
//---------------------------------------------------------------------------------
void ListProcDeInit(PackHnd PackDataHnd, WindowPtr ListWindow)
{
ParameterBlock block;
(*PackDataHnd)->ListWindow = NULL;
CloseWindow(ListWindow);
CALL4D(kEX_KILL_PROCESS,&block);
}